﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace proyectoENS
{
    public partial class frmLogin : Form
    {
        private bool _ifLogin;
        public bool IfLogin
        {
            get
            {
                return _ifLogin;
            }
        }
        private int intentos;
        public frmLogin()
        {
            InitializeComponent();
           button1.Click += new EventHandler(button1_Click);
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            //label1.Text = "Bienvenido al sistema de turnos Secheep" + Environment.NewLine + "Por favor, inicie sesion para continuar";
        }
        private void button1_Click(object sender, EventArgs e)
        {
            lblAux.Text = string.Empty;
            intentos++;
            if (Login.LogIn(tbxNusu.Text, tbxPass.Text) == true)
            {
                this._ifLogin = true;
                this.Close();
            }
            else
            {
                this._ifLogin = false;
                lblAux.Text = ("Datos invalidos, intente nuevamente");
                if (intentos > 5)
                {
                    MessageBox.Show("Se han realizado demasiados intentos");
                    this.Close();
                }
            }
        }

        private void tbxNusu_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Return))
                tbxPass.Focus();
        }

        private void tbxPass_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == Convert.ToChar(Keys.Return))
                button1_Click(this, null);
        }

        private void frmLogin_Load_1(object sender, EventArgs e)
        {
            tbxNusu.Text = "arrio89";
            tbxPass.Text = "arrio89";
        }
    }
}
